package com.whfc.ms.api.cfg.service.factory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author qzexing
 * @version 1.0
 * @date 2021-07-30 15:29
 */
@Service
public class ConfigCenterServiceFactory {


    @Autowired
    private final Map<String, ConfigCenterService> serviceMap = new ConcurrentHashMap<>();


    public ConfigCenterService getConfigCenterService(String module) {
        switch (module) {
            case ConfigCenterModuleConstant.MACH_FREQ:
            case ConfigCenterModuleConstant.MACH_STRATEGY:
            case ConfigCenterModuleConstant.MACH_FENCE:
                return serviceMap.get(ConfigCenterServiceConstant.MACH_SERVICE);
            case ConfigCenterModuleConstant.EMP_FREQ:
            case ConfigCenterModuleConstant.EMP_GATE:
            case ConfigCenterModuleConstant.EMP_FENCE:
                return serviceMap.get(ConfigCenterServiceConstant.EMP_SERVICE);
            case ConfigCenterModuleConstant.FVS_PLATFORM:
                return serviceMap.get(ConfigCenterServiceConstant.FVS_SERVICE);
            case ConfigCenterModuleConstant.FIM_ALG_TYPE:
                return serviceMap.get(ConfigCenterServiceConstant.FIM_SERVICE);
            case ConfigCenterModuleConstant.OPEN_LICENSE:
            case ConfigCenterModuleConstant.OPEN_LICENSE_RULE:
                return serviceMap.get(ConfigCenterServiceConstant.OPEN_SERVICE);
            default:
                return null;
        }
    }

}
